﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Ryder_US_Website.BUS;

namespace Ryder_US_Website.Presentation.Guest
{
    public partial class DichVu : System.Web.UI.Page
    {
        private String[] arr_trash = new String[2] { "Còn sử dụng", "Đã xóa" };
        List<RUS_ServiceDetail> list = new List<RUS_ServiceDetail>();
        ResourceManager rm;
        CultureInfo ci;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Location"] == null)
            {
                Session["Location"] = "vi-VN";
            }
            Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Location"].ToString());
            rm = new ResourceManager("Resources.SitMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
            Session["Lang"] = Session["Location"].ToString().Substring(0, 2);

            list = ServiceDetailBUS.GetAll();
            DataTable dt = new DataTable();
            dt.Columns.Add("#");
            dt.Columns.Add("Loại");
            dt.Columns.Add("Tên dịch vụ");
            //dt.Columns.Add("Đơn vị tính");
            //dt.Columns.Add("Trọng lượng tối thiểu");
            //dt.Columns.Add("Trọng lượng tối đa");
            dt.Columns.Add("Đơn giá");
            dt.Columns.Add("Ghi chú");
            DataRow row = null;
            for (int i = 0; i < list.Count; i++)
            {
                RUS_ServiceDetail kq = new RUS_ServiceDetail();
                row = dt.NewRow();
                row["#"] = (i + 1).ToString();
                row["Loại"] = ServiceBUS.GetActiveServiceByID(list[i].ServiceDetail_ServiceID).Service_name;
                row["Tên dịch vụ"] = list[i].ServiceDetail_name;
                
                //row["Đơn vị tính"] = list[i].ServiceDetail_unit;
                //row["Trọng lượng tối thiểu"] = list[i].ServiceDetail_unitMin;
                //row["Trọng lượng tối đa"] = list[i].ServiceDetail_unitMax;
                row["Đơn giá"] = list[i].ServiceDetail_price.ToString("F0", CultureInfo.InvariantCulture);
                row["Ghi chú"] = list[i].ServiceDetail_description;
                //row["Tình trạng"] = arr_trash[list[i].ServiceDetail_trash];
                dt.Rows.Add(row);
            }
            grvServiceDetail.DataSource = dt;
            grvServiceDetail.AllowPaging = true;
            grvServiceDetail.PageSize = 20;
            grvServiceDetail.DataBind();
        }

        protected void grvServiceDetail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int i = e.Row.RowIndex;
                e.Row.Cells[1].Text = Server.HtmlDecode(e.Row.Cells[1].Text);
            }
        }

        protected void grvServiceDetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvServiceDetail.PageIndex = e.NewPageIndex;
            grvServiceDetail.DataBind();
        }

        public void LoadString(CultureInfo ci)
        {
            lbService.Text = rm.GetString("Service", ci);
        }
    }
}
